<template>
  <div class="werapp">
    <div class="login">
      <div class="login-panel">
        <div class="login-top">
          <h3>欢迎登录 - MMALL管理系统</h3>
        </div>
        <div class="panel-body">
          <input
            type="text"
            placeholder="User Name"
            v-model="logins.username"
            class="form-control"
          />
          <input
            type="password"
            placeholder="Password"
            v-model="logins.password"
            class="form-control"
          />
          <button type="submit" class="btn" @click="login1">登录</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { login } from "../../http/index.js";
export default {
  name: "Login",
  data() {
    return {
      logins: {
        username: "admin",
        password: "admin",
      },
    };
  },
  methods: {
    login1() {
      login(this.logins).then((res) => {
        console.log(res);
        if (res.data.status == 0) {
          alert(res.data.msg);
          var obj={
            data:this.logins.username,
            time:Date.now(),
            expire:1000*60*30
          }
          localStorage.setItem("admin",JSON.stringify(obj))
          this.$router.push({name:"Index"})
        }else{
            alert(res.data.msg);
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.werapp {
  height: 100vh;

  .login {
    margin-left: 33.33333333%;
    width: 33.33333333%;
    background: white;
    .login-panel {
      border-color: #ececec;
      margin-top: 25%;
      margin-bottom: 20px;
      background-color: #fff;
      .login-top {
        padding: 15px 15px 0;
      }
    }
    .panel-body {
      padding: 15px;
      box-sizing: border-box;
      .form-control {
        width: 100%;
        height: 34px;
        display: block;
        font-size: 14px;
        margin-bottom: 15px;
      }
      .btn {
        padding: 10px 16px;
        font-size: 18px;
        line-height: 1.3333333;
        border-radius: 6px;
        background-color: #337ab7;
        border-color: #2e6da4;
        width: 100%;
      }
    }
  }
}
</style>